import { post } from '@/request/http'
import store from '@/store'

//查询
export const orderPlanInfo = ({
  attCode,
  cmtContractNo,
  attStatus,
  attCreatetimeStart,
  attCreatetimeEnd,
  PageIndex,
  PageSize
}) => {
  return post('/FTKJWLHYPT/orderPlan/orderPlanList', {
    Data: {
      Parameters: {
        FTKJWLHYPT: {
          fltUuid: store.state.user.FLT_UUID_DX_H,
          attDptId: store.state.user.DPTID_DX_H, // 集团
          cmtContractNo,
          attCode,
          attStatus,
          attCreatetimeStart,
          attCreatetimeEnd
        }
      },
      Orderby: {},
      PageIndex: {
        FTKJWLHYPT: PageIndex
      },
      PageSize: {
        FTKJWLHYPT: PageSize
      }
    }
  })
}


// 运单列表
export const getWillBillListByAttCode = ({
  orderCode,
  billCode,
  billStatus,
  trkCode,
  driver,
  isPlatform
}) => {
  return post('/FTKJWLHYPT/transoprt/getWayBillList', {
    Data: {
      Parameters: {
        FTKJWLHYPT: {
          attCode: orderCode,
          wabCode: billCode,
          wabStatus: billStatus,
          trkNo: trkCode,
          drvName: driver,
          fltUuid: store.state.user.FLT_UUID_DX_H,
          isPlatform
        }
      },
      Orderby: {},
      PageIndex: {
        FTKJWLHYPT: '1'
      },
      PageSize: {
        FTKJWLHYPT: '30'
      }
    }
  })
}

//所有合同数据（企业Id、部门Id不传查所有）
export const getContractAll = () => {
  return post('/FTKJWLHYPT/contract/findListPage', {
    Data: {
      Parameters: {
        FTKJWLHYPT: {
        }
      }
    }
  })
}
//合同下拉
export const getDealInfos = ({
  PageIndex,
  PageSize,
  cmtContractNo
}) => {
  return post('/FTKJWLHYPT/orderPlan/getContract', {
    Data: {
      Parameters: {
        FTKJWLHYPT: {
          fltId: store.state.user.FLT_UUID_DX_H,
          dptId: store.state.user.DPTID_DX_H,
          cmtContractNo
        }
      },
      Orderby: {},
      PageIndex: {
        FTKJWLHYPT: PageIndex
      },
      PageSize: {
        FTKJWLHYPT: PageSize
      }
    }
  })
}

//新增订单
export const addOrderPlanInfo = ({

  cmtContractNo, //合同号

  attCltId,//客户ID
  attCltName,//attCltName
  attCEtpId,//客户企业ID
  attRemark,//备注
  odcSProvince,//发货地省
  orDeliverypointcity,//发货地市
  odcSArea,//发货地详细地址
  odcDProvince,//收货方省
  orReveivingpartytelcity,//收货方市
  adcDAddress,//收货方详细地址
  attWrkdate,//客户要求作业时间
  attFinwrkdate,//客户要求完成时间
  adcVehicleRequirements,//车型

  adcCltId,//客户ID
  adcConsigner,//委托人
  adcLinkperson,//联系人
  adcLinkphone,//联系电话
  adcTel,//手机
  adcQq,//QQ,
  adcWechat,//微信
  adcEmail,//EMAIL
  orReveivingparty, //收货方
  orReveivingpartycontacts,//收货方联系人
  orReveivingpartytel,//收货方联系方式
  orShipper,//发货方
  orShippercontacts,//发货方联系人
  orShippertel,//发货方联系方式

  adcSAddress,//发货地地址
  odcDArea,//收货地区县
  trkLong,//车长要求
  adcSX,//X坐标
  adcSY,//Y坐标
  adcSSwrkdate, //装车时间段（开始）
  adcSEwrkdate, //装车时间段（结束）
  adcDX, //X坐标
  adcDY, //Y坐标
  adcDSfinwrkdate, //卸车时间段（开始）
  adcDEfinwrkdate,  //卸车时间段（结束）
  adcXcfzff, //卸车费支付方（RV_DOMAIN=‘卸车费用付方’）
  adcJsfh, //结算方式
  adcJsfhValue, //结算类型
  adcDistanced, //里程
  adcDistancedtime, //运输时间

  //货物
  goodsForm,
  gdsName,
  gdsType,
  gdsQuantity,
  gdsWeight,
  gdsVolumn,
  gdsRemark,
  gdsPrice
}) => {
  return post('/FTKJWLHYPT/transoprt/addOrEditOrderInfo', {
    Data: {
      Parameters: {
        FTKJWLHYPT: {
          Client: {
            cltId: adcCltId,//客户ID
            cltName: attCltName, //客户姓名
            cltEptId: attCEtpId, //客户企业id
            adcConsigner,//委托人
            cltContact: adcLinkperson,//联系人
            cltCtctel: adcLinkphone,//联系电话
            adcTel,//手机
            adcQq,//QQ,
            adcWechat,//微信
            adcEmail,//EMAIL
          },
          Attorney: {
            cmtContractNo: cmtContractNo,
            fltUuid: store.state.user.FLT_UUID_DX_H,
            attDptId: store.state.user.DPTID_DX_H,
            attCltId: attCltId,
            attCltName,
            attCEtpId,
            attRemark,
            attCreator: store.state.user.USR_CODE_DX_H,
            odcSProvince,
            orDeliverypointcity,
            odcSArea: adcSAddress,
            odcDProvince,
            orReveivingpartytelcity,
            adcDAddress,
            attWrkdate,
            attFinwrkdate,
          },
          AttDoc: {
            adcVehicleRequirements,
            adcEtpId: store.state.user.FLT_UUID_DX_H,
            adcCltId: attCltId,
            adcConsigner,
            adcLinkperson,
            adcLinkphone,
            adcTel,
            adcQq,
            adcWechat,
            adcEmail,
            orReveivingparty,
            orReveivingpartycontacts,
            orReveivingpartytel,
            orShipper,
            orShippercontacts,
            orShippertel,
            creator: store.state.user.USR_CODE_DX_H,
            odcSProvince,
            orDeliverypointcity,
            odcSArea,
            adcSAddress,
            odcDProvince,
            orReveivingpartytelcity,
            odcDArea,
            adcDAddress,
            attWrkdate,
            attFinwrkdate,
            trkLong,
            adcSX,
            adcSY,
            adcSSwrkdate,
            adcSEwrkdate,
            adcDX,
            adcDY,
            adcDSfinwrkdate,
            adcDEfinwrkdate,
            adcXcfzff,
            adcJsfh,
            adcJsfhValue,
            adcDistanced,
            adcDistancedtime
          },
          Goods: goodsForm
        }
      }
    }
  })
}
//region 修改
export const EditOrderPlanInfo = ({
  uuid,
  cmtContractNo,
  attCltId,//客户ID
  attCltName,//attCltName
  attCEtpId,//客户企业ID
  attRemark,//备注
  odcSProvince,//发货地省
  orDeliverypointcity,//发货地市
  odcSArea, // 发货地区县
  adcSAddress,//发货地详细地址
  odcDProvince,//收货方省
  orReveivingpartytelcity,//收货方市
  odcDArea,//收货地区县
  adcDAddress,//收货方详细地址
  attWrkdate,//客户要求作业时间
  attFinwrkdate,//客户要求完成时间
  adcVehicleRequirements,//车型要求

  // adcCltId,//客户ID
  adcConsigner,//委托人
  adcLinkperson,//联系人
  adcLinkphone,//联系电话
  adcTel,//手机
  adcQq,//QQ,
  adcWechat,//微信
  adcEmail,//EMAIL
  orReveivingparty, //收货方
  orReveivingpartycontacts,//收货方联系人
  orReveivingpartytel,//收货方联系方式
  orShipper,//发货方
  orShippercontacts,//发货方联系人
  orShippertel,//发货方联系方式


  trkLong,//车长要求
  adcSX,//X坐标
  adcSY,//Y坐标
  adcSSwrkdate, //装车时间段（开始）
  adcSEwrkdate, //装车时间段（结束）
  adcDX, //X坐标
  adcDY, //Y坐标
  adcDSfinwrkdate, //卸车时间段（开始）
  adcDEfinwrkdate,  //卸车时间段（结束）
  adcXcfzff, //卸车费支付方（RV_DOMAIN=‘卸车费用付方’）
  adcJsfh, //结算方式
  adcJsfhValue, //结算类型
  adcDistanced, //里程
  adcDistancedtime, //运输时间

  //货物
  goodsForm,
  gdsName,
  gdsType,
  gdsQuantity,
  gdsWeight,
  gdsVolumn,
  gdsRemark,
  gdsPrice
}) => {
  return post('/FTKJWLHYPT/transoprt/addOrEditOrderInfo', {
    Data: {
      Parameters: {
        FTKJWLHYPT: {
          Attorney: {
            uuid,
            cmtContractNo: cmtContractNo,
            fltUuid: store.state.user.FLT_UUID_DX_H,
            attCltId: attCltId,
            attCltName,
            attCEtpId,
            attRemark,
            adcSAddress,
            lastmodifier: store.state.user.USR_CODE_DX_H,
            odcSProvince,
            orDeliverypointcity,
            odcDProvince,
            orReveivingpartytelcity,
            adcDAddress,
            attWrkdate,
            attFinwrkdate,
          },
          AttDoc: {
            adcVehicleRequirements,
            adcEtpId: store.state.user.FLT_UUID_DX_H,
            adcCltId: attCltId,
            adcConsigner,
            adcLinkperson,
            adcLinkphone,
            adcTel,
            adcQq,
            adcWechat,
            adcEmail,
            orReveivingparty,
            orReveivingpartycontacts,
            orReveivingpartytel,
            orShipper,
            orShippercontacts,
            orShippertel,
            lastmodifier: store.state.user.USR_CODE_DX_H,
            odcSProvince,
            orDeliverypointcity,
            adcSAddress,
            odcDProvince,
            orReveivingpartytelcity,
            odcDArea,
            odcSArea,
            adcDAddress,
            attWrkdate,
            attFinwrkdate,
            trkLong,
            adcSX,
            adcSY,
            adcSSwrkdate,
            adcSEwrkdate,
            adcDX,
            adcDY,
            adcDSfinwrkdate,
            adcDEfinwrkdate,
            adcXcfzff,
            adcJsfh,
            adcJsfhValue,
            adcDistanced,
            adcDistancedtime
          },
          Goods: goodsForm
        }
      }
    }
  })
}
//endregion
//运力删除
export const delTmAttendancecar = ({ wdcTime,
  wdcTrkId }) => {
  return post('/FTKJWLHYPT/transoprt/delTmAttendancecar', {
    Data: {
      Parameters: {
        FTKJWLHYPT: {
          wdcFltId: store.state.user.FLT_UUID_DX_H,
          wdcTime,
          wdcTrkId
        }
      }
    }
  })
}
